package pattern.behavioral.visitor;

class Horse {

  public void eat() {
    System.out.println("马吃草");
  }
}

class BlackHorse extends Horse {

  @Override
  public void eat() {
    System.out.println("黑马吃草");
  }
}

class WhiteHorse extends Horse {

  @Override
  public void eat() {
    System.out.println("白马吃草");
  }
}

class Visitor {

  public void ride(Horse horse) {
    System.out.println("horse");
  }

  public void ride(BlackHorse horse) {
    System.out.println("BlackHorse");
  }

  public void ride(WhiteHorse horse) {
    System.out.println("WhiteHorse");
  }
}

public class Client {

  public static void main(String[] args) {
    Horse h = new BlackHorse();
    h.eat();
    Visitor visitor = new Visitor();
    visitor.ride(h);
  }
}
